<template>
	<view class='content'>
		<view class="cu-list menu card-menu margin-top-xl shadow-lg">
			<view class="cu-item arrow" >
				<view class="content" @click="navto('/pages/set/child/AccountME')">
					<text class=""></text>
					<text class="text-grey">账号管理</text>
				</view>
			</view>
		</view>
		<view class="cu-form-group">
			<view class="title">新消息通知</view>
			<switch @change="SwitchA" :class="switchA?'checked':''" :checked="switchA?true:false"></switch>
		</view>
		<view class="cu-list menu card-menu margin-top-xl shadow-lg">
			<view class="cu-item arrow" >
				<view class="content" @click="navto('/pages/set/child/privacy')">
					<text class=""></text>
					<text class="text-grey">隐私</text>
				</view>
			</view>
		</view>
		<view class="cu-list menu card-menu margin-top-xl shadow-lg">
			<view class="cu-item arrow" >
				<view class="content" @click="navto('/pages/myabout/ablout')">
					<text class=""></text>
					<text class="text-grey">关于</text>
				</view>
			</view>
		</view>
		<view class="tui" @click="exit">退出登录</view>
	</view>
</template>
<script>
	import { mapState, mapActions} from 'vuex';  
	export default {
		components: {
				
		},
		data() {
			return {
				switchA: true,
				stus:'',
				stu:''
			};
		},
		created() {
	
		},
		onShow() {
			this.$msgchat.initwork();
		},
		onLoad(option) {
			this.stu = uni.getStorageSync('yinstus');
			if(this.stu == 1){
				this.switchA = true
			}else if(this.stu == 2){
				this.switchA = false
			}
			console.log(this.stu);
		},
		methods:{
			...mapActions(['logout']),
			SwitchA(e) {
				this.switchA = e.detail.value;
				if(e.detail.value == true){
					this.stus = 1
				}else if(e.detail.value == false){
					this.stus = 2
				}
				var obj = {
					is_news_notice : this.stus
				}
				this.$common.requests('/api/user/updatenotice', obj).then(res => {
					// this.$api.msg(res.data.msg);
					uni.setStorageSync('yinstus', this.stus);
					console.log(uni.getStorageSync('yinstus'))
				})
			},
			navto(urls){
				uni.navigateTo({
					url: urls
				})
			},
			exit(){
				uni.showModal({
					 content: '确定要退出登录吗?',
					success: res => {
						if(res.confirm){
							// this.logout();
							uni.redirectTo({
							    url: '/pages/login/login'
							});
						}
					}
				})
			}
		},
	}
</script>

<style lang='scss'>
	page{
		height: 100%;
		background: $uni-color-bei;
	}
	.cu-list{
		background: #fff;
		margin-left: 0!important;
		margin-right: 0!important;
		border-radius: 0!important;
		margin-top: 30upx;
		/* width: 100%; */
	}
	.cu-form-group{
		margin-top: 30upx;
	}
	.text-grey{
		color: $uni-text-color;
	}
	.tui{
		margin-top: 30upx;
		width: 100%;
		text-align: center;
		background: #fff;
		padding: 27upx 0 27upx 0;
	}
	.content{
		height: 100%;
	}
</style>
